package org.jeeasy.system.modules.user.domain;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.dromara.autotable.annotation.mysql.MysqlTypeConstant;
import org.dromara.mpe.autotable.annotation.Column;
import org.dromara.mpe.autotable.annotation.Table;
import org.jeeasy.common.core.annotation.dict.Dict;
import org.jeeasy.common.core.base.BaseEntity;
import org.jeeasy.common.core.handler.userpwd.IUserPassword;
import org.jeeasy.system.enums.user.SysUserStatusEnum;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDate;

/**
 * 系统用户
 *
 * @author Alps
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@Table(value = "sys_user", comment = "系统用户")
public class SysUser extends BaseEntity<SysUser> implements IUserPassword, Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Column(comment = "用户名", length = 32, notNull = true)
    private String username;

    @Column(comment = "用户编号", length = 8)
    private Long userNo;

    @Column(comment = "电话号码", length = 18)
    private String phone;

    @Column(comment = "真实姓名", length = 32)
    private String realName;

    @Column(comment = "性别", length = 1, type = MysqlTypeConstant.TINYINT)
    private Integer sex;

    @Column(comment = "生日")
    private LocalDate birthday;

    @JsonIgnore
    @Column(comment = "密码", length = 100)
    private String password;

    @JsonIgnore
    @Column(comment = "--", length = 12)
    private String salt;

    @TableField(fill = FieldFill.INSERT)
    @Dict(dictEnum = SysUserStatusEnum.class)
    @Column(comment = "状态", length = 1, type = MysqlTypeConstant.TINYINT)
    private Integer status;

    @Column(comment = "邮箱", length = 255)
    private String email;

    @Column(comment = "头像", length = 255)
    private String avatar;

    @Column(comment = "备注", length = 255)
    private String remark;

}
